package com.ruoyi.web.controller.netty.demo;

import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicInteger;

@ChannelHandler.Sharable
@Slf4j
public class NettyShareChannelHandler extends ChannelDuplexHandler {
    AtomicInteger increment = new AtomicInteger(0);

    @Override
    public void read(ChannelHandlerContext ctx) throws Exception {
        int count = increment.incrementAndGet();
        log.info("接收到的请求总数为:" + count);
        super.read(ctx);
    }
}
